using System;
using System.IO;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Security.Cryptography;
using System.Net;
using System.Text;
using PQT.API.File;
using System.Threading;

using System.Collections.Generic;
using System.Text.RegularExpressions;


namespace cbmobile
{
    public static class DACHelper
    {

        #region Private method

        public static string StripDiacritics(object accented)
        {
            Regex regex = new Regex(@"\p{IsCombiningDiacriticalMarks}+");

            string strFormD = accented.ToString().Replace(".", "-").Normalize(NormalizationForm.FormD);
            return regex.Replace(strFormD, String.Empty).Replace('\u0111', 'd').Replace('\u0110', 'D');
        }

        private static string prepareUrlText(string urlText)
        {
            urlText = StripDiacritics(urlText);
            Regex purifyUrlRegex = new Regex("[^-a-zA-Z0-9_ ]");
            Regex dashesRegex = new Regex("[-_ ]+", RegexOptions.Compiled);

            urlText = purifyUrlRegex.Replace(urlText, "");
            urlText = urlText.Trim();
            urlText = dashesRegex.Replace(urlText, "-");
            return urlText;

        }

        public static string ConvertUrlText(object p_urlText)
        {
            string urlText = StripDiacritics(p_urlText);
            Regex purifyUrlRegex = new Regex("[^-a-zA-Z0-9_ ]");
            Regex dashesRegex = new Regex("[-_ ]+", RegexOptions.Compiled);

            urlText = purifyUrlRegex.Replace(urlText, "");
            urlText = urlText.Trim();
            urlText = dashesRegex.Replace(urlText, "-");
            return urlText;

        }

        #endregion

    }

}
